﻿#region
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
#endregion

namespace YTBZ
{
    [WebService(Namespace = "http://tempuri.org/")]
    

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    
    [System.Web.Script.Services.ScriptService]
    public class DDL : System.Web.Services.WebService
    {
        #region GetBack
        public string[] getDB(string preFixText, string strFixType)
        {
            return getDB(preFixText, "", strFixType);
        }
        public string[] getDB(string preFixText,string contextKey, string strFixType)
        { 
            SortedList SDList = new SortedList();
            SDList["V_FIXTEXT"] = preFixText;
            SDList["V_FIXTYPE"] = strFixType; 
            SDList["V_SUPPLIERCODE"] = contextKey;
            DB TT = new DB();
            return getItem(TT.proGetDT(SDList, "PRO_SYS.GETFIX"), "FIXHEAD", "FIXINFO");
        } 
        public string[] getItem(DataTable dt,string strField1,string strField2)
        {
            int iLength = (dt.Rows.Count > 20 ? 20 : dt.Rows.Count);
            string[] strBack = new string[iLength];
            for (int i = 0; i < iLength; i++)
            {
                DataRow dr = dt.Rows[i];
                strBack[i] = dr[strField1].ToString() + " " + dr[strField2].ToString();
            }
            return strBack;
        }
        #endregion

        #region Test 
        [WebMethod]
        public string[] GetDDLTest(string prefixText, int count)
        {
            DataTable dtDDL = new DataTable();dtDDL.Columns.Add("TT1"); dtDDL.Columns.Add("TT2"); DataRow dr = dtDDL.NewRow();
            dr = dtDDL.NewRow(); dr["TT1"] = "111111"; dr["TT2"] = "名字名字" + prefixText; dtDDL.Rows.Add(dr);
            dr = dtDDL.NewRow(); dr["TT1"] = "121111"; dr["TT2"] = "其他其他" + prefixText; dtDDL.Rows.Add(dr);
            dr = dtDDL.NewRow(); dr["TT1"] = "123111"; dr["TT2"] = "只有三条" + prefixText; dtDDL.Rows.Add(dr); 
            return getItem(dtDDL,"TT1", "TT2");
        }
        #endregion


        [WebMethod(EnableSession = true)]
        public string[] GetDDLDEPTID(string prefixText, int count){ return getDB(prefixText,"DEPT"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLMATERIAL(string prefixText, int count) { return getDB(prefixText, "MATERIAL"); }
        public string[] GetDDLMATERIALTT(string prefixText, int count, string contextKey) { return getDB(prefixText, contextKey, "MATERIAL"); } 

        [WebMethod(EnableSession = true)]
        public string[] GetDDLSUPPLIER(string prefixText, int count) { return getDB(prefixText, "SUPPLIER"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLLBBATYPE(string prefixText, int count) { return getDB(prefixText, "LBBATYPE"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLGATE(string prefixText, int count) { return getDB(prefixText, "GATE"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLCARTYPE(string prefixText, int count) { return getDB(prefixText, "CARTYPE"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLASSY(string prefixText, int count) { return getDB(prefixText, "ASSY"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLSENDCAR(string prefixText, int count) { return getDB(prefixText, "SENDCAR"); }
        [WebMethod(EnableSession = true)]
        public string[] GetDDLCHEST(string prefixText, int count) { return getDB(prefixText, "CHEST"); }



    }
}
